<?
include_once($_SERVER['DOCUMENT_ROOT']."/lucy/config.php");
include_once(INC.'sess.php');
include_once(CLA."speech.class.php");
include_once(CLA."lucy_feelings.class.php");
$lucy_feeling = new Lucy_feelings();

if($_POST['word'] != ""){
	$word = str_replace(" ", "+", $_POST['word']);
	$type = $_SESSION['help']['type'];
	$feeling = $_SESSION['help']['feeling'];

	$speech = new Speech($feeling, $word, $type, 1);
	if($speech->save_response()){
		$lucy_feeling->change(1);
		
		$_SESSION['print']['echo'] = "Pievienots jauna atbilde <u><b>$word</b></u> :)";
		$mod_name = "print";
		$send = "<meta http-equiv='refresh' content=\"0;url=http://localhost/lucy/sys/mod/".$mod_name.".php?inSess=".session_id()."\">";
		echo $send;
	}
}elseif($_POST['cancel'] == 1){
		$_SESSION['print']['echo'] = "Neko nesaglabāju :(";
		
		$lucy_feeling->change(-1);

		$mod_name = "print";
		$send = "<meta http-equiv='refresh' content=\"0;url=http://localhost/lucy/sys/mod/".$mod_name.".php?inSess=".session_id()."\">";
		echo $send;
}


//=-=========================================================================
$about = "Un es jūtos ";
$about .= translate_feeling($_SESSION['help']['feeling']);

if($_SESSION['help']['type'] == "sajūta"){
	$start = "jūtos ";
}

$in_word = str_replace("+", " ", $_SESSION['in']['word']);
$in_speech = new Speech();
$type = $in_speech->get_type($_SESSION['in']['word']);

echo "Palīdzi man atbildēt! :(";
echo "<br/>Ko lai es saku, ja tu teici <b>' $in_word '</b> [$type]";
echo "<br/>$about<br/>";

?>
<br/><br/>
<form action="" method="POST">
	<input type="text" name="word" value="<?=$start;?>">
	<input type="submit" name="submit" value="  OK  ">
</form>

<form action="" method="POST">
	<input type="hidden" name="cancel" value="1">
	<input type="submit" name="submit" value="Atcelt">
</form>